package net.hn.hnms.biz.project.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.project.domain.ConstructionProgress;
import net.hn.hnms.biz.project.request.ConstructionProgressReq;
import net.hn.hnms.biz.project.service.IConstructionProgressService;
import net.hn.hnms.biz.project.vo.ConstructionProgressVo;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 刘昊
 * 施工进度
 * @date 2024-03-18 9:35
 */
@Api(value = "施工进度", tags = {"施工管理"})
@RestController
@RequestMapping("/constructionManagement/progress")
public class ConstructionProgressController {

    @Autowired
    private IConstructionProgressService constructionProgressService;

    @ApiOperation("上传施工进度报告")
    @PostMapping("/uploadReport")
    @AutoSetMineCode
    @Log(title = "上传施工进度报告", businessType = BusinessType.INSERT)
    public R<Void> uploadReport(@Validated @RequestBody ConstructionProgressReq req) {
        return constructionProgressService.insertReq(req);
    }

    /**
     * 未启用
     * @return void
     */
    @ApiOperation("删除施工进度")
    @ApiImplicitParam(name = "idList", value = "要删除的id值,用逗号间隔", required = true, allowMultiple = true, dataType = "String", paramType = "query")
    @DeleteMapping("delete")
    @Log(title = "删除施工进度", businessType = BusinessType.DELETE)
    @Deprecated
    public R<Void> delete(@RequestParam("idList") List<String> idList) {
        return constructionProgressService.deleteList(idList);
    }

    @ApiOperation("查询施工进度详情")
    @PostMapping("/selectDetails")
    @Log(title = "查询施工进度详情", businessType = BusinessType.UPDATE)
    public R<List<ConstructionProgressVo>> selectDetails(@RequestBody ConstructionProgressReq req) {
        return constructionProgressService.selectDetails(req);
    }

    @ApiOperation("查询施工进度")
    @PostMapping("/selectPageList")
    @AutoSetMineCode
    @Log(title = "查询施工任务", businessType = BusinessType.UPDATE)
    public R<ResponsePage<ConstructionProgress>> page(ConstructionProgressReq accidentInfoReq, PageQuery pageQuery) {
        return R.ok(constructionProgressService.selectPageList(accidentInfoReq, pageQuery));
    }
}
